home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / tool / artemis1 / src / makemap.awk < prev    next >
Encoding:
AWK Script  |  1993-09-05  |  1.0 KB  |  51 lines

  1. # makemap.awk : 386link の .MAP 出力より、メモリー使用一覧
  2. # を作成する。
  3.  
  4. BEGIN {
  5.     do { getline; } while ($0 != "Segment map");
  6.     getline; getline; getline
  7. }
  8.  
  9. {
  10.     if ($0 == "")
  11.         exit;
  12.     name = substr($0,1,14);        gsub(/[ \t]/,"",name);
  13.     type = substr($0,29,13);    gsub(/[ \t]/,"",type);
  14.     size = hextoi(substr($0,59,8));
  15.  
  16.     if (substr(name,1,1) == "_")
  17.         name = "?other" type
  18.     if (type == "")
  19.         type = (name=="CSEG"?"CODE":name=="DSEG"?"DATA":"NONAME");
  20.  
  21.     sizelist[name] += size
  22.     typelist[name] = type
  23.     sizetotal[type] += size
  24. }
  25.  
  26. function hextoi(hexstr)
  27. {
  28.     n = 0;
  29.     toupper(hexstr);
  30.     gsub(/[ \t]/,"",hexstr);
  31.     for (i=1; i<=length(hexstr); i++)
  32.         n = n * 16 + index("0123456789ABCDEF",substr(hexstr,i,1)) - 1;
  33.     return n;
  34. }
  35.  
  36. END {
  37.     for (i in sizelist)
  38.     {
  39.         rate = (sizelist[i]/sizetotal[typelist[i]]) * 100;
  40.         printf("%-14s %8d %7.2f(%%) (%-6s) ",i,sizelist[i],rate,typelist[i]);
  41.         rr = int(rate*3);
  42.         if (rr > 25)
  43.             printf("*");
  44.         else {
  45.             for (j=0; j<rr; j++)
  46.                 printf(":");
  47.         }
  48.         printf("\n");
  49.     }
  50. }
  51.